import requests

# 登录
url = "http://127.0.0.1:8000/api/user/login"
r = requests.post(url, json={'userName': 'admin', 'password': '123456', 'remember': False})
# print(r.text)
# print(r.json())
assert r.json()['message'] == '成功'
print(r.cookies)
# for cookie in r.cookies:
#     print(cookie)
cookies = requests.utils.dict_from_cookiejar(r.cookies)
print(cookies)
print("----------------------------")

# 查询学科
url = "http://127.0.0.1:8000/api/admin/education/subject/page"
cs = {"level": None, "pageIndex": 1, "pageSize": 10}
r = requests.post(url, json=cs,cookies=cookies)
print(r.text)
print(r.json())
assert r.json()['message'] == '成功'
assert r.json()['code'] == 1
